package com.cskaoyan.service;

import com.cskaoyan.bean.baseresultVO.WxResultListVo;
import com.cskaoyan.bean.domain.Address;
import com.cskaoyan.bean.domain.AddressExample;
import com.cskaoyan.mapper.AddressMapper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author lirui
 * @Date 2021/12/2 22:15
 * @describe:
 */

@Service
public class WxAddressServiceImpl implements WxAddressService {
    @Autowired
    AddressMapper addressMapper;


    @Override
    public WxResultListVo queryAddress() {
        //获取用户的id（目前没完成）
        Integer useId=1;
        AddressExample addressExample = new AddressExample();
        AddressExample.Criteria criteria = addressExample.createCriteria();
        criteria.andUserIdEqualTo(1);
        List<Address> addresses = addressMapper.selectByExample(addressExample);
        PageInfo info = new PageInfo(addresses);
        Integer pages=info.getPages();
        Integer total = (int)info.getTotal();
        WxResultListVo<Address> wxResultListVo = new WxResultListVo();
        wxResultListVo.setList(addresses);
        wxResultListVo.setPage(1);
        wxResultListVo.setLimit(15);
        wxResultListVo.setPages(pages);
        wxResultListVo.setTotal(total);
        return wxResultListVo;


    }
}
